﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace canyinguanlixitong
{
    public partial class frmshoying : Form
    {
        public frmshoying()
        {
            InitializeComponent();
        }
        string str = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";
        private void frmshoying_Load(object sender, EventArgs e)
        {
           
            xiala();
            comboBox1.SelectedIndex = 0;
        }
        //下拉列表
        public void xiala() {
            SqlConnection conn = new SqlConnection(str);
            DataSet ds = new DataSet("Student");
            string sql = "select userID,userName from UserTpye ";
            SqlDataAdapter asdf = new SqlDataAdapter(sql,conn);
            asdf.Fill(ds, "Student");
            DataRow row = ds.Tables["Student"].NewRow();
            row["userID"] = -1;
            row["userName"] = "全部";
            ds.Tables["Student"].Rows.InsertAt(row,0);
            this.comboBox1.DataSource = ds.Tables["Student"];
            this.comboBox1.ValueMember = "userID";
            this.comboBox1.DisplayMember = "userName";
        }
        private void tabPage1_Click(object sender, EventArgs e)
        {
          
        }
        public void add() {
            SqlConnection conn = new SqlConnection(str);
            DataSet ds = new DataSet("Student");
            string sql = @"select xfTime,fcCzid,dcJai,userAdd,userName,xfZong,dcQi
from [Summary of consumption],UserTpye,[Room table bill],[Ordering management]
where [Summary of consumption].xfUserTpye=UserTpye.userID and [Summary of consumption].fcID=[Room table bill].fcID
and [Summary of consumption].dcID=[Ordering management].dcID ";
            SqlDataAdapter asdf = new SqlDataAdapter(sql, conn);
            asdf.Fill(ds,"Student");
            dataGridView1.DataSource = ds.Tables["Student"];

        }

        private void button2_Click(object sender, EventArgs e)
        {
            add();
        }
    }
}
